import {request} from "./index";
import {baseUrl} from "./config";
//上传文件
export const upload_file = (fileBinary, fileType = 'image') => {
    uni.showLoading({
        title:'上传中...'
    })
    return new Promise(resolve => {
        let key = uni.getStorageSync('key');
        uni.uploadFile({
            url: baseUrl +'/api/base/upload_img',
            filePath: fileBinary,
            fileType,
            name: 'file',
            success: res => {
                uni.hideLoading();
                console.log(res);
                console.log(typeof res.data)
                if (typeof res.data == 'string') {
                    resolve(JSON.parse(res.data).datas?.src)

                }else resolve(res.data.datas?.src)
            }
        })
    })
}

// 微信登录
export const wx_login = (data={}) => {
  return request({
      url:'login/login',
      data
  })
}
// 获取用户信息
export const get_member_info = (data={}) => {
    return request({
        url:'member/get_member_info',
        data
    })
}
// 获取轮播图
export const get_banner = (data={}) => {
    return request({
        url:'index/get_banner',
        data
    })
}

//获取基础设置
export const get_show = (data={}) => {
    return request({
        url:'index/get_show',
        data
    })
}
//修改用户信息
export const update_weixin_member = (data={}) => {
    return request({
        url:'member/update_weixin_member',
        data
    })
}
//修改申请信息（注册）
export const set_apply = (data={}) => {
    return request({
        url:'member/set_apply',
        data
    })
}
//队伍列表（下拉）
export const get_contingent_list_select = (data={}) => {
    return request({
        url:'index/get_contingent_list_select',
        data
    })
}
//班组列表（下拉）
export const get_teams_groups_list_select = (data={}) => {
    return request({
        url:'index/get_teams_groups_list_select',
        data
    })
}
//工种列表（下拉）
export const get_work_type_list_select = (data={}) => {
    return request({
        url:'index/get_work_type_list_select',
        data
    })
}
//设置项目
export const set_project = (data={}) => {
    return request({
        url:'project/set_project',
        data
    })
}
//项目分类列表（下拉）
export const get_project_type_list_select = (data={}) => {
    return request({
        url:'index/get_project_type_list_select',
        data
    })
}

//项目详情
export const get_project_info = (data={}) => {
    return request({
        url:'project/get_project_info',
        data
    })
}
//生成二维码
export const add_qrcode = (data={}) => {
    return request({
        url:'index/add_qrcode',
        data
    })
}
//题目列表
export const get_subject_list = (data={}) => {
    return request({
        url:'project/get_subject_list',
        data
    })
}
//题目分类列表（下拉）
export const get_subject_type_list_select = (data={}) => {
    return request({
        url:'index/get_subject_type_list_select',
        data
    })
}
//获取项目已参用户列表
export const get_member_project_log_list = (data={}) => {
    return request({
        url:'project/get_member_project_log_list',
        data
    })
}
//项目列表
export const get_project_list = (data={}) => {
    return request({
        url:'project/get_project_list',
        data
    })
}
//审核
export const set_member_project_log_state = (data={}) => {
    return request({
        url:'project/set_member_project_log_state',
        data
    })
}
//答题记录列表（错题本列表）
export const get_member_project_subject_log_list = (data={}) => {
    return request({
        url:'member_project_subject_log/get_member_project_subject_log_list',
        data
    })
}
//答题记录详情（错题本详情）
export const get_member_project_subject_log_info = (data={}) => {
    return request({
        url:'member_project_subject_log/get_member_project_subject_log_info',
        data
    })
}

//用户列表
export const get_user_list = (data={}) => {
    return request({
        url:'admin/get_user_list',
        data
    })
}

//积分变化记录
export const get_member_integral_log_list = (data={}) => {
    return request({
        url:'member/get_member_integral_log_list',
        data
    })
}

//积分变化记录
export const edit_member_integral = (data={}) => {
    return request({
        url:'admin/edit_member_integral',
        data
    })
}
//帮用户兑换商品
export const exchange_goods = (data={}) => {
    return request({
        url:'admin/exchange_goods',
        data
    })
}
//获取用户信息
export const get_member_info_admin = (data={}) => {
    return request({
        url:'admin/get_member_info',
        data
    })
}

//参与项目（无题目）
export const add_member_project_log = (data={}) => {
    return request({
        url:'staff/add_member_project_log',
        data
    })
}



//获取已参与项目列表
export const get_member_project_log_list_user = (data={}) => {
    return request({
        url:'staff/get_member_project_log_list',
        data
    })
}
//商品列表
export const get_goods_list = (data={}) => {
    return request({
        url:'index/get_goods_list',
        data
    })
}
//商品详情
export const get_goods_info = (data={}) => {
    return request({
        url:'index/get_goods_info',
        data
    })
}
//获取默认地址
export const get_default_address_info = (data={}) => {
    return request({
        url:'member_address/get_default_address_info',
        data
    })
}

//获取所有地址
export const get_address_list = (data={}) => {
    return request({
        url:'member_address/get_address_list',
        data
    })
}
//添加商品订单（兑换商品）
export const add_order = (data={}) => {
    return request({
        url:'staff/add_order',
        data
    })
}

//商品订单列表
export const get_order_list = (data={}) => {
    return request({
        url:'staff/get_order_list',
        data
    })
}

//商品订单详情
export const get_order_info = (data={}) => {
    return request({
        url:'staff/get_order_info',
        data
    })
}
//商品订单详情地址详情
export const get_address_info = (data={}) => {
    return request({
        url:'member_address/get_address_info',
        data
    })
}
//设置地址
export const add_address = (data={}) => {
    return request({
        url:'member_address/add_address',
        data
    })
}
//删除订单
export const del_order = (data={}) => {
    return request({
        url:'staff/del_order',
        data
    })
}
//删除订单
export const get_project_subject_info = (data={}) => {
    return request({
        url:'staff/get_project_subject_info',
        data
    })
}
//答题
export const answer_project_subject = (data={}) => {
    return request({
        url:'staff/answer_project_subject',
        data
    })
}


